#Boa:Frame:ControleAcesso
# -*- coding: cp1252 -*-

import wx
import wx.lib.masked.textctrl

def create(parent):
    return ControleAcesso(parent)

[wxID_CONTROLEACESSO, wxID_CONTROLEACESSOBUTTONLOGIN, 
 wxID_CONTROLEACESSOLOGIN, wxID_CONTROLEACESSOLOGINTEXT, 
 wxID_CONTROLEACESSOPANEL1, wxID_CONTROLEACESSOSENHA, 
 wxID_CONTROLEACESSOSTATICBITMAP1, wxID_CONTROLEACESSOSTATICBITMAP2, 
 wxID_CONTROLEACESSOSTATICLINE1, wxID_CONTROLEACESSOSTATICLINE2, 
 wxID_CONTROLEACESSOSTATICLINE3, wxID_CONTROLEACESSOSTATICTEXT1, 
 wxID_CONTROLEACESSOSTATICTEXT2, wxID_CONTROLEACESSOSTATICTEXT3, 
] = [wx.NewId() for _init_ctrls in range(14)]

class ControleAcesso(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_CONTROLEACESSO, name=u'ControleAcesso',
              parent=prnt, pos=wx.Point(604, 168), size=wx.Size(529, 517),
              style=wx.DEFAULT_FRAME_STYLE, title=u'Login')
        self.SetClientSize(wx.Size(521, 484))
        self.Center(wx.BOTH)

        self.panel1 = wx.Panel(id=wxID_CONTROLEACESSOPANEL1, name='panel1',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(521, 484),
              style=wx.TAB_TRAVERSAL)
        self.panel1.SetBackgroundColour(wx.Colour(255, 255, 255))

        self.Login = wx.TextCtrl(id=wxID_CONTROLEACESSOLOGIN, name=u'Login',
              parent=self.panel1, pos=wx.Point(138, 248), size=wx.Size(166, 21),
              style=0, value=u'')

        self.staticText1 = wx.StaticText(id=wxID_CONTROLEACESSOSTATICTEXT1,
              label=u'Login', name='staticText1', parent=self.panel1,
              pos=wx.Point(88, 248), size=wx.Size(34, 16), style=0)
        self.staticText1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Tahoma'))

        self.staticText2 = wx.StaticText(id=wxID_CONTROLEACESSOSTATICTEXT2,
              label=u'Senha', name='staticText2', parent=self.panel1,
              pos=wx.Point(88, 288), size=wx.Size(40, 16), style=0)
        self.staticText2.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Tahoma'))

        self.Senha = wx.TextCtrl(id=wxID_CONTROLEACESSOSENHA, name=u'Senha',
              parent=self.panel1, pos=wx.Point(138, 288), size=wx.Size(166, 21),
              style=wx.TE_PASSWORD, value=u'')

        self.buttonLogin = wx.Button(id=wxID_CONTROLEACESSOBUTTONLOGIN,
              label=u'Login', name=u'buttonLogin', parent=self.panel1,
              pos=wx.Point(237, 320), size=wx.Size(63, 24), style=0)
        self.buttonLogin.Bind(wx.EVT_BUTTON, self.OnButtonLoginButton,
              id=wxID_CONTROLEACESSOBUTTONLOGIN)

        self.staticBitmap1 = wx.StaticBitmap(bitmap=wx.Bitmap(u"Imagens/logotipo300dpi-30%.jpg",
              wx.BITMAP_TYPE_JPEG), id=wxID_CONTROLEACESSOSTATICBITMAP1,
              name='staticBitmap1', parent=self.panel1, pos=wx.Point(8, 8),
              size=wx.Size(500, 176), style=0)

        self.staticLine1 = wx.StaticLine(id=wxID_CONTROLEACESSOSTATICLINE1,
              name='staticLine1', parent=self.panel1, pos=wx.Point(84, 232),
              size=wx.Size(352, 2), style=0)
        self.staticLine1.Center(wx.HORIZONTAL)

        self.LoginText = wx.StaticText(id=wxID_CONTROLEACESSOLOGINTEXT,
              label=u'Login', name=u'LoginText', parent=self.panel1,
              pos=wx.Point(88, 200), size=wx.Size(66, 29), style=0)
        self.LoginText.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Tahoma'))
        self.LoginText.SetToolTipString(u'staticText3')

        self.staticBitmap2 = wx.StaticBitmap(bitmap=wx.Bitmap(u'Imagens/Imagens-Icone_Seguranca_Login (1).png',
              wx.BITMAP_TYPE_PNG), id=wxID_CONTROLEACESSOSTATICBITMAP2,
              name='staticBitmap2', parent=self.panel1, pos=wx.Point(328, 248),
              size=wx.Size(77, 77), style=0)

        self.staticText3 = wx.StaticText(id=wxID_CONTROLEACESSOSTATICTEXT3,
              label=u'Um produto MVR solu\xe7\xf5es em sistemas de informa\xe7\xe3o\xae 2012',
              name='staticText3', parent=self.panel1, pos=wx.Point(88, 464),
              size=wx.Size(294, 13), style=0)

        self.staticLine2 = wx.StaticLine(id=wxID_CONTROLEACESSOSTATICLINE2,
              name='staticLine2', parent=self.panel1, pos=wx.Point(84, 360),
              size=wx.Size(352, 2), style=0)
        self.staticLine2.Center(wx.HORIZONTAL)

        self.staticLine3 = wx.StaticLine(id=wxID_CONTROLEACESSOSTATICLINE3,
              name='staticLine3', parent=self.panel1, pos=wx.Point(0, 456),
              size=wx.Size(520, 2), style=0)

    def __init__(self, parent):
        self._init_ctrls(parent)

        self.Login.SetValue('MVR')
        self.Senha.SetValue('OSPODAR')
        self.buttonLogin.SetFocus()

    def OnButtonLoginButton(self, event):
        from Class_ControleFuncionario import *
        from Frame_JanelaPrincipal import *
        
        Login = self.Login.GetValue()
        Senha = self.Senha.GetValue()
        
        C = ControleFuncionario()
        Funcionario = C.VerificarLogin(Login, Senha)
        if Funcionario <> False:
         
            Main = JanelaPrincipal(None, Funcionario)
            Main.Show()
            self.Close()

        else:
            m = "Login e/ou Senha incorretos !"
            t = "Login"
            wx.MessageBox(m,t,wx.ICON_ERROR)
            self.Login.SetFocus()
            self.Login.SetSelection(-1,-1)
